<?php
//require_once("DBAccess.php");
///**
// * Created by IntelliJ IDEA.
// * User: sarahub
// * Date: 12/2/12
// * Time: 7:37 PM
// * To change this template use File | Settings | File Templates.
// */
//class GTPort
//{
//    public $db;
//
//    function __construct( $db_host = "127.0.0.1", $db_user = "root", $db_password = "", $database = "cs4400" ) {
//        $this->db = new DBAccess($db_host, $db_user, $db_password, $database );
//    }
//
//    public function create_account( $userName, $password, $userType )
//    {
//        $db = $this->db;
//
//        $result = $db->get_object("select * from regular_user where Username='%s'", null, $userName);
//
//        if ($result) {
//            // the account already exists, let user know
//            return null;  // the account already exists and you can't create it.
//
//        } else {
//            $db->insert( "insert into regular_user (Username, Password)
//                                values ( '%s', '%s' )",
//                $userName,
//                $password );
//            //insert into student table if student
//            if($userType == 1){
//                $db->insert( "insert into student (Username)
//                                values ( '%s' )",
//                    $userName);
//
//            }
//            //faculty member
//            else{
//                $db->insert( "insert into faculty (Username)
//                                values ( '%s' )",
//                    $userName);
//            }
//
//        }
//
//        return $this->login( $userName, $password);
//    }
//
//    //login the user and set the cookie
//    public function login($userName, $password){
//        if (($password != "") && ($userName != "")){
//            $db = $this->db;
//
//            $result = $db->get_object("select * from regular_user where Username='%s' and password='%s'", null, $userName, $password);
//            if ($result){
//                setcookie('Username', $userName, false, '/');
//                return $result;
//            }
//        }
//        return null;
//    }
//
//    //read the cookie to get the current user
//    public function getCurrentUser(){
//        $userName = $_COOKIE['Username'];
//
//        if ($userName){
//            $db = $this->db;
//            $user = $db->get_object("select * from regular_user where Username='%s'", null, $userName);
//            if ($user){
//                return $user;
//            }
//        }
//
//        return null;
//
//    }
//    //$paramArray can be null or an associative array with keys and values
//    public function redirect($phpFile, $paramArray){
//        $params = array();
//        if ($paramArray == null){
//
//                header("Location: ".$phpFile);
//        }
//        else{
//            foreach($paramArray as $key => $value) {
//                $params[] = $key."=".urlencode($value);
//            }
//            $msg = join('&', $params);
//            header("Location: ".$phpFile."?".$msg);
//
//        }
//    }
//
//<?php foreach($departments as $dept){ ?>
<!--                <option value="--><?//= $dept->Dept_ID ?><!--">--><?//= $dept->Dept_Name ?><!--</option>-->
<!--            --><?php //} ?>
<!---->
<!--}-->
